// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
const MAX_LIMIT = 100
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let useType = event.useType
  let type = event.type
  if(useType=='登陆'){
    let userData = event.userData
    return await db.collection("userInfo")
    .where(
      {
        _openid:wxContext.OPENID
      }
    )
    .update({
      data:userData
    })
  }
}